/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: Faculty of informatics, Burapha University 01
 * License Type: Purchased
 */
package cn.imvc.app.entities;

import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="area")
public class Area implements Serializable {
	public Area() {
	}
	
	private int id;
	
	private String name;
	
	private cn.imvc.app.entities.Area parent;
	
	private byte sort = 0;
	
	private byte deep = 1;
	
	private String region;
	
	private java.util.Set address = new java.util.HashSet();
	
	private java.util.Set address1 = new java.util.HashSet();
	
	private java.util.Set address2 = new java.util.HashSet();
	
	private java.util.Set expressFee = new java.util.HashSet();
	
	private java.util.Set area = new java.util.HashSet();
	
	public void setId(int value) {
		this.id = value;
	}
	
	@Column(name="id", nullable=false)	
	@Id	
	@GeneratedValue(generator="CN_IMVC_APP_ENTITIES_AREA_ID_GENERATOR")	
	@org.hibernate.annotations.GenericGenerator(name="CN_IMVC_APP_ENTITIES_AREA_ID_GENERATOR", strategy="identity")	
	public int getId() {
		return id;
	}
	
	@Transient	
	public int getORMID() {
		return getId();
	}
	
	/**
	 * 地区名称
	 */
	public void setName(String value) {
		this.name = value;
	}
	
	/**
	 * 地区名称
	 */
	@Column(name="name", nullable=false, length=255)	
	public String getName() {
		return name;
	}
	
	/**
	 * 排序
	 */
	public void setSort(byte value) {
		this.sort = value;
	}
	
	/**
	 * 排序
	 */
	@Column(name="sort", nullable=false)	
	public byte getSort() {
		return sort;
	}
	
	/**
	 * 地区深度，从1开始
	 */
	public void setDeep(byte value) {
		this.deep = value;
	}
	
	/**
	 * 地区深度，从1开始
	 */
	@Column(name="deep", nullable=false)	
	public byte getDeep() {
		return deep;
	}
	
	/**
	 * 大区名称
	 */
	public void setRegion(String value) {
		this.region = value;
	}
	
	/**
	 * 大区名称
	 */
	@Column(name="region", nullable=true, length=255)	
	public String getRegion() {
		return region;
	}
	
	public void setParent(cn.imvc.app.entities.Area value) {
		this.parent = value;
	}
	
	@ManyToOne(targetEntity=cn.imvc.app.entities.Area.class, fetch=FetchType.LAZY)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.LOCK})	
	@JoinColumns({ @JoinColumn(name="parentId", referencedColumnName="id", nullable=false) })	
	@org.hibernate.annotations.LazyToOne(value=org.hibernate.annotations.LazyToOneOption.NO_PROXY)	
	@org.hibernate.annotations.Index(name="area_parent_id")	
	public cn.imvc.app.entities.Area getParent() {
		return parent;
	}
	
	public void setAddress(java.util.Set value) {
		this.address = value;
	}
	
	@OneToMany(mappedBy="province", targetEntity=cn.imvc.app.entities.Address.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getAddress() {
		return address;
	}
	
	
	public void setAddress1(java.util.Set value) {
		this.address1 = value;
	}
	
	@OneToMany(mappedBy="city", targetEntity=cn.imvc.app.entities.Address.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getAddress1() {
		return address1;
	}
	
	
	public void setAddress2(java.util.Set value) {
		this.address2 = value;
	}
	
	@OneToMany(mappedBy="county", targetEntity=cn.imvc.app.entities.Address.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getAddress2() {
		return address2;
	}
	
	
	public void setExpressFee(java.util.Set value) {
		this.expressFee = value;
	}
	
	@OneToMany(mappedBy="area", targetEntity=cn.imvc.app.entities.ExpressFee.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getExpressFee() {
		return expressFee;
	}
	
	
	public void setArea(java.util.Set value) {
		this.area = value;
	}
	
	@OneToMany(mappedBy="parent", targetEntity=cn.imvc.app.entities.Area.class)	
	@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.LOCK})	
	@org.hibernate.annotations.LazyCollection(org.hibernate.annotations.LazyCollectionOption.TRUE)	
	public java.util.Set getArea() {
		return area;
	}
	
	
	public String toString() {
		return toString(false);
	}
	
	public String toString(boolean idOnly) {
		if (idOnly) {
			return String.valueOf(getId());
		}
		else {
			StringBuffer sb = new StringBuffer();
			sb.append("Area[ ");
			sb.append("Id=").append(getId()).append(" ");
			sb.append("Name=").append(getName()).append(" ");
			if (getParent() != null)
				sb.append("Parent.Persist_ID=").append(getParent().toString(true)).append(" ");
			else
				sb.append("Parent=null ");
			sb.append("Sort=").append(getSort()).append(" ");
			sb.append("Deep=").append(getDeep()).append(" ");
			sb.append("Region=").append(getRegion()).append(" ");
			sb.append("Address.size=").append(getAddress().size()).append(" ");
			sb.append("Address1.size=").append(getAddress1().size()).append(" ");
			sb.append("Address2.size=").append(getAddress2().size()).append(" ");
			sb.append("ExpressFee.size=").append(getExpressFee().size()).append(" ");
			sb.append("Area.size=").append(getArea().size()).append(" ");
			sb.append("]");
			return sb.toString();
		}
	}
	
}
